« first day (2414 days earlier)      last day (2532 days later) » 
00:00 - 20:0020:00 - 00:00

Xeo
8:03 PM
@Mysticial Vita is sooo not dead in Japan
it's very beloved there
 
8:16 PM
I do wonder why games tend to be more for consoles than PCs? Is it because of piracy? Or hardware normalization?
 
Sony/Nintendo/Microsoft pays developers to make exclusives
also Japan is a huge console market for some reason
(actually many different reasons, too much to fit in this textbox)
 
I soo do not want to pay for a console when I already have so much computer hardware sitting around from my programming hobby.
 
I know your sentiment
My approach is to wait 10-15 years for emulators
 
And they take up space too.
I also need to budget myself for a new server this year. Since my quad-opteron is getting a little bit too dated.
 
today I learned about the null object pattern and it is weirding me out.
especially the part where the examples I keep finding use data objects as the type for the null object
I can understand types with contracts which can be fulfilled trivially having a minimal implementation
 
8:27 PM
@milleniumbug That's too long for me. lol
 
but shouldn't you tell the user of the thing you're returning that it's not actually a thing?
 
Though I did enjoy playing Sonic from my childhood on an emulator.
 
@jaggedSpire what is it?
 
since any explanation I'd give will be best summarized by "it's this stupid thing where...," I'll link you to the wiki:
In object-oriented computer programming, a Null Object is an object with no referenced value or with defined neutral ("null") behavior. The Null Object design pattern describes the uses of such objects and their behavior (or lack thereof). It was first published in the Pattern Languages of Program Design book series. == Motivation == In most object-oriented languages, such as Java or C#, references may be null. These references need to be checked to ensure they are not null before invoking any methods, because methods typically cannot be invoked on null references. The Objective-C language takes...
 
@jaggedSpire Sounds like one of those things that everybody reinvents without knowing they reinvented something.
 
8:31 PM
I don't take issue with the possibility of having what is effectively an std::optional<> for a return value--that makes sense. Or with always returning a collection from a function with a collection return type, and just making it null if nothing was found
 
@jaggedSpire reminds me of the unit type from Algebraic Data Types
 
@jaggedSpire the null object pattern is something else
 
@Mysticial I have a null logger in my C# code, so I'm certainly another data point
and I don't take issue with allowing the passage of a minimal implementation of an interface into code, either
 
@jaggedSpire I have at least 3 of such things in my pi program. A null logger is something that's planned for an upcoming refactor of the logging mechanism.
My stupid pi program has gone for 8 years without a proper logging interface. And now it's starting to catch up to me.
 
but returning a minimal implementation of an interface as a fallback value for a function to avoid checking for null in client code seems like it kicks the can down the road and forces the client to check the interface to see how to check for the null object
 
8:36 PM
@jaggedSpire have you ever seen logging code that double checks whether the stream object it's being passed is really writing to stderr?
 
@LucDanton meant to say "just making it empty" there. What is it then?
 
@jaggedSpire It depends on whether the object is an "essential" part of the functionality of the program.
Logging isn't. So it's perfect for null-objecting.
My Pi program has a similar thing for checkpointing computations. If you give it the null checkpointing object, it simply won't make any checkpoints and you won't be able to resume the computation after restarting the program. But it works since checkpointing isn't essential to the functionality of the task.
 
@jaggedSpire there is an object, and it does fulfil the contract. it does so by doing nothing (for some value of nothing)
 
@LucDanton no, because the interface is being filled by the thing it's passed. Passing it in implies that the caller knows the argument is valid--the code is allowed to do some simple sanity checks in the interest of failing fast and with comprehensible errors but it's not required just the pokite thing to do
I understand the minimal functionality getting passed as an argument thing
 
@jaggedSpire there’s nothing else to understand
 
8:40 PM
what I don't understand is people saying you should return minimal functionality in place of null when you can't find/construct anything
 
@jaggedSpire Minimal to satisfy the contract of the interface.
 
@jaggedSpire ah, yes. people. I understand why you are weirded out now
 
@jaggedSpire Maybe it's the difference between nullptr and having a featureless class that's the important part
It's still certainly better than SEGMENTATION FAULT because you wanted to use a pointer and not a sentinel type
 
@VermillionAzure but the featureless class makes it so you have to figure out the proper way of checking for <no object found> instead of just using the dead simple and always deducable if (ret == null)
when clients shouldn't give a damn, and it's an irrelevant detail, sure
 
@jaggedSpire no, that’s really doing it wrong
 
8:46 PM
@jaggedSpire What if the class is like this?
variant<A, B>
Can you tell it's an A::null or a B::null?
 
you should really divorce the null object pattern from checking for absence
 
null is not usable as an object, which is why people check for it
 
@milleniumbug null should not be a value though. It should be a type.
 
a class implementing null object pattern is supposed to satisfy preconditions, but in a minimal way
if you check whether it implements null object pattern, you're indeed doing it wrong
null logger satisfies preconditions so need to check for that one
 
...so having a null object for a Person would only be a good idea in very specific contexts, and presumably only where it's immutable?
 
8:49 PM
I don't see how you can have a null object Person
 
neither do I and since the examples I find use that, it's doing my head in
 
/dev/null is a good example of a null output stream. Writing to it does nothing, but it satisfies the contract that you can push bytes into it.
 
I don't have any issue with a null logger or anything that can meaningfully implement an interface minimally, and especially statelessly.
that passes all my mental sanity checks
 
11 mins ago, by Luc Danton
@jaggedSpire there’s nothing else to understand
you’re there, congrats
 
...so just ignore the people who use mutable aggregate data types as their example of a Good Type For a Null Object?
 
8:52 PM
maybe? I don’t know
 
I'm going to do that.
thank you everyone
 
@jaggedSpire if it’s any help, what makes a neutral object (substituting for the 'null' terminology for a sec) is with respect to something else: an algorithm, an operation or operations. a null stream is so with respect to logging code, which is an altogether not so helpful thing to say of course. so if you want to conceive of a neutral person data type, you’d probably need to figure with respect to what
 
@LucDanton ...that actually makes the concept fit a great deal better, thanks.
 
e.g. passing a do-nothing function [](event_t event) {} can be neutral with respect to passing a callback that reacts to events. but [] { throw some_error {}; } can be neutral when it comes to registering an exception handler
 
@jaggedSpire I don't really like Null Object
seems like we already got a null object - nullptr.
or the empty std::optional if they finally standardised that
 
9:00 PM
@Puppy The idea with a null object is that it behaves like a valid object. nullptr certainly does not behave like any pointer.
A null logger does nothing when you pass stuff to it. It doesn't crash or throw exceptions. It just silently does nothing.
 
well, that's not necessarily true
the calling code may incur unnecessary expenses like taking locks and whatnot
 
The idea with null objects is the caller doesn't need to know it's null when calling it.
If you need a if before you call it, it's not a null object.
Both nullptr and std::optional require checks.
So I feel like you're basically using a different terminology than everyone else here.
 
no, I think you just don't understand the point that I've just made
 
@EtiennedeMartel or just missing the point
 
if the callee doesn't know that it's a null object, then they can't take shortcuts based on that information that may yield faster or more reliable implementations
 
9:03 PM
That is, you're describing something completely different, and then saying you don't like that different thing, which has nothing to do with what others are saying.
 
The point of this discussion is null.
 
so trying to hide the null from them doesn't really do nothing.
the callee still puts in all the same work as a normal object
 
I don't think the point of the null object idiom is to be efficient.
 
also it inherently seems to me like the pattern only makes sense when you have a function whose sole purpose is to perform some random side effect
and then you're just like, "I just don't need that side effect"
which kinda feels like you're just injecting random side effects everywhere
 
What is a logger, if not a bunch of side effects?
 
9:05 PM
What is a logger!? A miserable pile of side effects!
3
 
well, yeah.
kinda seems to me like instead of logging to a logger, just return that information that you would have logged and let the caller decide if it needs to go in a log or not
then they do not need to inject a null logger
 
Loggers are usually external dependencies that are injected into a system.
 
the only trouble comes in some failure cases where e.g. the program is terminated before the caller gets to do the logging
 
The caller might no know where the logger comes from.
With a null logger you can easily disable logging without expecting users to check for nulls everywhere.
 
in the scheme I have just outlined, there are no null checks.
you simply return the data you want to log and then it can go all the way up the call stack if it has to until somebody knows whether or not they want to log it
 
9:09 PM
Usually you kinda want to log events as soon as they arrive.
Log events are not exceptions, they don't "bubble up".
They're just dumped as they happen.
 
not automatically, but that does not mean you can't bubble them up if you don't want to
 
It doesn't have to be about side-effects. Take another example from my pi program. The task parallelizer. The interface consists of a function: virtual void run_in_parallel(task A, task B). Most of the implementations actually run both A and B at the same time either using explicit threads, or a pool, or something else. But there's a "null parallelizer" that is 2 lines - A.run(); B.run(); It satisfies the contract of running the tasks, and it works correctly.
But it doesn't actually parallelize.
 
you can certainly do such a thing using the technique I have outlined above, where you simply return task A and task B, and then the caller can parallelize them or not as they need
 
Somewhat besides the point of null object idiom, but in this case, the idea is to separate the task decomposition from the parallelization. The code doesn't (and shouldn't) care how the tasks are run. All it does it provide the tasks that can be run in parallel. Then the parallelizer object handles it.
 
Um... I bet functional programming has this already solved somewhere
 
9:13 PM
that property is preserved in the scheme I have outlined
 
something something monoids and identity operator
Oh I see
 
since it's the code's caller who decides how to run the tasks you have returned
 
Ahhh
@milleniumbug Think of a Null object as the identity element for a given operator.
 
@Puppy I think we're talking past each other. The point here is that rather than doing if (parallelizer == nullptr){A.run(); B.run();} everywhere, you just blindly call parallelizer->run_in_parallel(A, B) and insert the null-parallelizer object if you want to disable the parallelism.
 
@Mysticial Rather than doing either of those things, just return std::pair<task>(A, B).
 
9:22 PM
@Puppy I don't get it. What does that accomplish?
 
@Mysticial The caller doesn't need to pass in a parallelizer at all. Therefore there's nothing that needs to be null or not null. The caller can simply directly do whatever they need.
 
what if the function you're doing this in is supposed to do something different and running tasks in parallel isn't the only part of its logic?
 
@Puppy So you're suggesting that the caller do a switch on every single different parallelizer implementation?
 
user406009
@jaggedSpire With enough monads, you could probably express those side effects as return values.
 
with enough monads anything is possible
 
9:24 PM
@Mysticial No, the caller simply directly calls the parallelizer they want to use with the returned values as the arguments. In this case the parallelizer does not need to be an interface at all but just some function that takes tasks and runs them.
 
user406009
Probably just need a decent Future monad.
 
@Puppy I don't think I understand. Where are these "returned values" coming from.
I think I'm missing the big picture that you have in mind.
 
@Mysticial You returned them, as above, from the code that currently calls a parallelizer.
 
@Puppy No, they don't get returned. They only get run. Nothing is being returned.
 
@Mysticial No, they get run in your current architecture, as opposed to the scheme which I have been suggesting in which they do get returned.
 
9:29 PM
Can you illustrate? Here's my current design:
Caller:
Task A = (...)
Task B = (...)
parallelizer->run_in_parallel(A, B):
The parallelizer is run-time determined.
 
well part of the problem is that I've been calling that the callee, not the caller.
 
oh, we had it backwards with respect to each other.
 
so that thing up there that you just posted returns those tasks.
then whoever calls that thing up there that you just posted simply invokes the parallelizer they want to use directly.
 
Oh ic. Enclose the logic that generates the tasks into a function that outputs task. Then toss the tasks into the parallelizer.
 
user406009
@Mysticial In theory, you could create the entire computation DAG, and then have a separate algorithm decide how to run that DAG.
 
user406009
9:35 PM
You can completely separate the scheduling from the specification of the work.
 
@Lalaland I've thought about doing it from a graph approach, but it's not at all simple.
 
user406009
I don't think it would really buy you much either
 
Yeah, putting aside the overhead of maintaining the DAG, the code needs to be written that way. And you lose the entire structure of nested scope lifetimes.
 
I'm merely saying that the null object pattern is completely extraneous if you don't inject totally random side effects into your functions in the first place
 
Recursive fork-join works much better with stack-based execution and scoped variable lifetimes.
 
9:38 PM
blech fork
not sure I'd say anything involving that works better
 
I'm not talking about linux-style process forking.
Everyone agrees that's terrible.
 
user406009
9:49 PM
@Mysticial Much better performance wise or style wise?
 
user406009
JavaScript Promises are practically the DAG approach and seem to lead to maintainable code.
 
@Lalaland I can't speak for the performance since I've never tried doing the DAG approach. But from a practical perspective, the recursive fork-join approach is much better with respect to the algorithms that I'm implementing and for resource management.
Granted, I haven't tried really hard to find ways to make it work. Mainly because I saw no benefit of going that route. Then you have to manage a shared data structure (the DAG) itself. So I left it at that.
 
10:09 PM
DAG should be immutable
you build it and then you run it
 
@Puppy Not always. Only if you can statically determine the DAG before you start executing it.
 
well, that's kinda the idea
you build the DAG and then you execute it
if you're still building it during execution then you have a problem ;p
 
Yeah, unfortunately, that won't work for my use cases.
Because, the work units are data-dependent. And even if they weren't, trying to build one for an entire computation will probably result in a DAG with the # of nodes on the order of billions to trillions depending on the size of the computation. So you'd need to do it on the fly. And not build too far ahead that you're putting a strain on resources.
 
hmm
are you sure you can't have nodes that are like, "Do this work on 99 billion inputs"?
 
10:25 PM
@Puppy Not really. Think about how you would go about building a DAG for a parallel quick-sort.
 
would not bother building more nodes than hardware concurrency can make use of
for smaller sorts than that I'd sub-sort in serial or just not bother expressing them as part of the DAG
 
That's the whole "task decomposition" concept. The algorithm code does need to have a hint at how much to sub-divide tasks.
 
I dunno
you already need such a hint to handle hardware concurrency limits, right?
you're not gonna try to spawn 1,000,000 threads to parallel-quick-sort a 1billion item array
 
Right, but if you spawn 16 tasks for a machine with 16 logical cores, and it turns out one of those tasks takes 10x longer than the rest, you're still screwed.
Or if they're all the same, but then a background task comes in and hogs a core thereby starving one of the tasks. (this is called, "jitter") And it's one of the most annoying problems I dealt with in the early days of my Pi program.
Even if I designed the algorithm to divide the tasks up in to perfectly equal parts, "jitter" fucks everything up.
 
nah
that would be if that parallel quicksort is the only thing running
but if you're executing a DAG of such large size, you can probably find some other task to work on
 
10:31 PM
The thing that saves your ass is the round-robin scheduler in the OS.
@Puppy The optimal # of tasks to decompose is typically on the order of more than 2x the hardware concurrency.
 
like some other part of the quicksort, sure
 
In routines where you have repeatedly need to spawn a bunch of tasks then wait for them to all finish, then spawn again, the "joining-time" is really sensitive to jitter and load imbalance.
Since at the tail of the DAG, you don't have any work-units left to run while you wait out the stragglers.
This isn't specific to a full async DAG approach to parallel programming, it's any sort of parallelism - including the fork-join and task-based models.
I found that best approach in these cases is to dynamically size the tasks such that they decrease in size towards the end.
But not all algorithms are suited to this.
 
What does round robin have to do with it? I think what saves you is that you have a lot of tasks (and fine granularity?) That way the imbalanced elements only happen at the end?
Or do you mean you do the scheduling "on the fly"?
 
@Mikhail If you have say 8 equally sized tasks running on 8 cores and a 9th background task kicks in, the OS will round-robin the time on the 9 tasks such that they all get roughly equal time. So the 8 tasks all get roughly the same CPU time and still all finish at roughly the same time. (though in practice, it's less ideal than this)
 
What if you just keep a pool of work units and as you expand the DAG, you assign new nodes to free work units? Then when a DAG node finishes, add that work unit back to the pool
And because a work unit can only be assigned once it's put into the pool again, race conditions won't be much of an issue.
 
10:39 PM
@Mikhail Dynamic scheduling. The nature of the tasks being decomposed takes into account the state of the scheduler and what else is running.
 
Maybe assign a separate pool for each subgroup
 
@Mysticial Yeah, an alternative solution is to have 8 workers and 1024938234 elements of work that get distributed to each worker, and only push work to a non-saturated queue.
 
@Aaron3468 Yes, that's how it would need to work for a "lengthy" computation.
 
Ah, but you're optimizing for short computations?
 
I used to see massive thread migration problem on Linux 3.14 (the one with the NT logo), but pinning them helped... Idk, the Linux scheduler is a constant battle.
 
10:42 PM
@Aaron3468 No, but rather the # of tasks that can be run at the same time grows and shrinks. And to be efficient, you need to handle the cases where the tag reduces to one node, then expands again.
Consider this:
 
Ah, so it's hard to predict when the computation is finishing (a simpler halting problem almost)
 
for (10000 items){
   do something
}

//  synchronize

for (10000 items){
   do something
}
@Aaron3468 Correct. This is fundamental to all parallelism scheme, but it's easier to manage on some than others.
In the "pure" DAG approach - even if you know the cost of each node, you're still left with presenting the scheduler with an NP-complete problem to solve.
 
Yeah, kind of wasteful to spin down all the work just because you have to synchronize. A better solution is finding a way to synchronize each thread into a predictable, well defined state and make sure all the threads hit that state.
That way they just need to say "Yep, I'm done, I'll take the next task while you wait for the others"
 
And let's not forget that schedulers need CPU to run as well. And they can bottleneck on a lot of cores if not designed correctly.
 
Hmm, but how do you keep them from trampling memory the straggling threads still need? Sounds like you'd need to keep a few different memory frames for different stages. At some point, those frames might all be used up and you'll need a way to get all the threads to catch up before moving forward.
 
10:50 PM
@Aaron3468 The resource management is one of the reasons why I've stayed away from the purely asynchronous approaches. (not to mention the difficulty of debugging)
It works fine if you do a purely functional approach where everything is passed in and returned by value or reference counted. But don't forget that now you've shifted the burden to a memory allocator that needs to take malloc() and free()s from a gazzilion threads at random times.
 
I can see why. Is it possible to keep the node around long enough to move computations to another thread if one gets stuck?
@Mysticial And that's where you start having to worry about hammering the cache and going too fast for the hardware ^^;
 
@Aaron3468 Depends on a lot of stuff. Usually, it's best to design it in a way where that doesn't happen.
In most cases, going purely functional is the best option anyway. It's easy to write, and from my experience, you only lose a factor of maybe 2x to implicit resource management by the memory allocator and other things.
As well as more memory consumption to fragmentation and other implementation specifics.
I've designed y-cruncher itself so that it doesn't touch the memory allocators at all (or very minimally). Mostly by using recursive static memory partitioning. But it's very difficult to get it right. My GitHub has purely function implementations of the same constants (so they allocate and free memory) - and while they use the same internals, the performance difference can be more than 2x.
 
Honestly it sounds like parallelism is a bit of black magic and hope. Sure, there's some good general rules, but it doesn't sound like there's any perfect solution yet
 
11:07 PM
No. Actually the guy described exactly the problems and how instead of using black magic how to use a non-functional approach.
 
11:30 PM
Ah, a lot of articles don't describe parallelism that well.
I should probably find a good book or start reading the manuals a bit more
 
Well blog posts were good to understand lock-free queues, but I've never found a motivation to use those in my work. What really helped me was drawing stuff on paper.
Fuck, I keep running into GPU memory fragmentation leading to spurious crashes with Thrust...
idk, is there something better than thrust?
5
 
00:00 - 20:0020:00 - 00:00

« first day (2414 days earlier)      last day (2532 days later) »