News for hackers. Stuff that matters.
Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by StefanKarpinski on Sunday October 11, 2020 @03:25PM (#24748324)
You may be missing the point of the comparison, which is this: to compare the performance of the de facto standard CSV parsers of each system when used the way that a typical user would use them, i.e. to parse a CSV file into a data frame.

Regarding your specific points:

1. Yes, it's possible to rig up some way of parsing in parallel in Python, like splitting the CSV file into multiple files and then parsing them in separate processes and then joining that. But no matter how you do it, you have to jump through extra hoops to do it. And that is not something most users do.

2. I don't entirely follow this point. Perhaps using PyArrow's parser would be faster than what is timed here, but is that what the typical Python data science user would do? Most Python users use Pandas and the CSV parsing that it provides. If that changes, then it would be good to do a new benchmark.

3. Yes, floating-point decoding is hard, but Julia's is fully accurate, so if it's also faster than Python's how is it an unfair comparison? If Julia was cheating by doing imprecise float parsing, sure, that would be a valid complaint, but it's not.

These "conflations" sound suspiciously like excuses. If float parsing is slow, make it faster. If concrete object decoding is slow, stop doing that. If threading would be faster, bite the bullet and use threading. If the language doesn't provide good support for these things, then maybe the language is at fault.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by orbifold on Sunday October 11, 2020 @05:49PM (#24749390)
I installed CSV.jl and tried it out on the insurance dataset from here "https://support.spatialkey.com/spatialkey-sample-csv-data/".

First import took >10s just to precompile and then CSV.File took 5.21s to read the file. A fresh pandas install takes ~10s to import and then reads this file in 81.2 ms ± 1.25 ms. CSV.jl takes 38 ms on a second run so it is twice as fast, however especially to someone that just starts using Julia, these >100x slowdowns constantly happen. Especially when using libraries that heavily rely on multiple dispatch specialisation for performance.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by ViralBShah on Sunday October 11, 2020 @06:19PM (#24749591)
I tried out the dataset you mention. I use the latest Julia 1.5.2 and CSV.jl 0.7.7 and load the CSV package in 1s, read the file first time in 5s and then in 0.03s the second time. The precompile time you mention is only for the very first time you download a new version of a package, which is then cached for subsequent sessions. Your generalization from a one time precompilation of the CSV.jl package to >100x slowdowns happening constantly is simply not true.

julia> @time using CSV 1.161851 seconds (2.05 M allocations: 131.757 MiB, 0.46% gc time)

julia> @time CSV.read("/Users/viral/Downloads/FL_insurance_sample.csv"); 4.884074 seconds (6.09 M allocations: 311.878 MiB, 1.90% gc time)

julia> @time CSV.read("/Users/viral/Downloads/FL_insurance_sample.csv"); 0.030916 seconds (147.27 k allocations: 11.361 MiB)

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by orbifold on Sunday October 11, 2020 @06:51PM (#24749805)
So I want to plot the data I just loaded. Since I wrote the comment I had closed the Julia window (not to make a point, btw.)

julia> import CSV (takes ~1-2 seconds)

julia> data = CSV.File("/User/orbifold/Downloads/FL_insurance_sample.csv) (takes seconds again...)

I want to explore the data. I vaguely remember there is Gadfly to do that. For some reason it depends on FFTW and a whole bunch of other packages, but the dependency story in Python is equally insane, so whatever. As I'm typing this, I'm waiting for Gadfly to precompile.

julia> @time import Gadfly (104.460307 seconds)

python> import matplotlib.pyplot as plt (~10s if you are unlucky and it has to generate the font cache)

Maybe it's a good idea to do a scatter plot of two of the fields? Let's find out

julia> @time Gadfly.plot(x=data.eq_site_limit, y=data.hu_site_limit) 0.320751 seconds

but that number is not accurate, in fact it took so long for the browser to open the result, that I had time to check the documentation on backends and see whether I'm missing something.

python> %time plt.scatter(data['eq_site_limit'], data['hu_site_limit']) 41.9 ms, a bit more for the window to open

Turns out that is not a useful plot... maybe a histogram?

julia> @time plot(x=data.eq_site_limit, Geom.histogram(bincount=10)) 0.042802 seconds

It in fact again takes several seconds until the browser shows a plot.

python> %time plt.hist(data["eq_site_limit"]) ~100ms

and the window with the plot opens instantly.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by ViralBShah on Sunday October 11, 2020 @07:03PM (#24749869)
Yes, Gadfly does have a large compile time. Reducing the time to first plot (essentially compilation time) has been a major focus for the 1.5 release.

People often use Plots.jl or PyPlot which have significantly lesser compile times.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by fermienrico on Sunday October 11, 2020 @08:22PM (#24750318)
@ViralBShah and @StefanKarpinski

I've had similar problems and so have many of my colleagues in silicon valley. No matter how you spin it and whatever benchmarks you show - Julia is a very slow fast language. :)

The UX of Julia needs major work - everything is just slow. If you've used Python for 10 years and it is like running through molasses. Benchmarks are meaningless for the most part. This is what bothers me about Julia's marketing - it claims to be fast, but in reality, precompilation time alone is a no go unless you're doing high-compute large batch processing. Julia cannot be come a general purpose language unless you fix these issues.

> These "conflations" sound suspiciously like excuses.

I think you're the one conflating total end-to-end time spent between given a task and going home early to see my kids if I used Python.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by ViralBShah on Sunday October 11, 2020 @09:22PM (#24750604)
Nobody is spinning anything here. Julia's compilation time is a known quantity. See my comment in https://news.ycombinator.com/item?id=24750559 about the different phases of Julia's compilation and execution (from a user's perspective).

Obviously, if you are not working on a problem that doesn't need Julia's speed (and makes it worth paying the compilation cost), and you are more comfortable with a different tool, you should use that. You may in fact be better off using Python, or shell scripting or even Excel.

Precompilation time in Julia is akin to `make` in a project with C code. You only compile the library once and use it repeatedly, until you update it. Is it a dealbreaker? Perhaps it is for you (assuming you are using precompilation in the right context). It is not for many who work with Julia day in and day out, and it is something that we continue to improve.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by fermienrico on Monday October 12, 2020 @12:13AM (#24751324)
Thanks for the insight. I think still for most engineering development - its mostly the one-off launch time that predominates. This is exactly why I don't use C++ for general purpose use.

There is something to be said about how easy Python makes development look - despite of the package management warts.

Btw, is there a reason why packages can't be precompiled and even distributed? I am sure you guys have thought about that.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by cbkeller on Monday October 12, 2020 @03:33AM (#24752227)
> precompiled and even distributed

There is work on this. This can be done with https://julialang.github.io/PackageCompiler.jl/dev/, but so far only to a rather large binary / “bundle”

IIUC, In principle it should be possible to do much better if you knew for sure at compile time which methods you would need to dispatch to for the data you ultimately want to run on.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by ViralBShah on Monday October 12, 2020 @09:34AM (#24754172)
Yes, you can use PackageCompiler for your collection of packages. We are also exploring doing this in the background when you add more packages.

The reason why we can't distribute precompiled .ji files at a package level is because of the way the package resolver works. It depends on the exact versions of dependencies of every package - and even for the same version of an end-user package, there can be slightly different versions of the dependencies installed depending on constraints imposed by other packages.

One major improvement coming in 1.6 is multi-threaded precompilation, and it will leverage all the cores you have.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by ddragon on Sunday October 11, 2020 @09:07PM (#24750525)
While I hope they'll keep the pace of improving the JIT lag (perhaps even adding a fast optional interpreter or AoT compilation of parts of code), the benchmarks are fine considering compilation is a one time paid ticket, while runtime is paid by usage. It's not just high compute, if I set up a website in Julia on a docker after the "cold start" (which can be handled before using packagecompiler if I don't want any client to feel the slow JIT compilation, as I obviously should) then it should run at the benchmarked runtime speed even if each request is very short (as the compilation price was paid already). That applies to most services in general, and even during development Julia programmers eventually learn not to cold start all the times (keeping the session open until you stop programming, so you again only pay the cost once).

Of course, any short task that must cold start like a bash script isn't convenient at all (and packagecompiler will generate a fat binary that runs fast, but it's still inconveniently fat if it's for something simple). And Julia's first impression is really important, which the "time to first plot" seems to affect the most (as you need to go deeper on the language to adapt to it's unusual workflow), so I agree that it's a UX priority.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by orbifold on Sunday October 11, 2020 @07:22PM (#24749979)
time to precompile Plots: 138s

julia> @time Plots.scatter(data.eq_site_limit, data.hu_site_limit) 5.461595 seconds

subsequent calls report significant speed ups compared to matplotlib, but render about as quickly

julia> @time Plots.histogram(data.eq_site_limit) 2.143983 seconds

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by ViralBShah on Sunday October 11, 2020 @09:14PM (#24750559)
There are 3 different phases:

1. Precompilation time: Only once when you install or upgrade a package.

2. First running time (that includes compilation time): When you call a function like `plot` the first time in a session

3. Second and subsequent running times: The compiled code is now in the cache, and what you see is the actual running time.

Thus what you are reporting here as precompilation (1) is not something that a user will see every time. What they will see is (2) for the first time in a session and (3) on subsequent plots. Could you confirm this is what you see - to ensure that those following along understand the terminology?

Here are the usage times I see when I use Plots on a daily basis in a Julia session:

  ~ exec '/Users/viral/Desktop/Julia_Releases/Julia-1.5.app/Contents/Resources/julia/bin/julia'
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.5.2 (2020-09-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/ |

   julia> @time using Plots
   11.341632 seconds (20.21 M allocations: 1.108 GiB, 2.87% gc time)

   julia> @time plot(1:10,1:10)
   2.291147 seconds (3.24 M allocations: 165.569 MiB, 7.80% gc time)
   (Another 2 seconds for the window to be drawn the first time on mac)

   julia> @time plot(1:10,1:10)
   0.000763 seconds (2.80 k allocations: 166.023 KiB)
Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by datanecdote on Sunday October 11, 2020 @03:50PM (#24748533)
> 2. I don't entirely follow this point. Perhaps using PyArrow's parser would be faster than what is timed here, but is that what the typical Python data science user would do?

I am a Python data science user. If data gets big enough such that loading time is a bottleneck, I use parquet files instead of CSV, and PyArrow to load them into pandas. It’s a one line change. The creator of Pandas is now leading the Arrow project. It’s very seamless. Don’t know if I’m typical but that’s me.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by ViralBShah on Sunday October 11, 2020 @06:25PM (#24749631)
Perhaps not directly relevant to your point here, but thought it would be interesting to anyone following along.

Jacob Quinn (karbacca) also has a Julia package for integrating Julia into the Arrow ecosystem: https://github.com/JuliaData/Arrow.jl

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by datanecdote on Sunday October 11, 2020 @08:46PM (#24750426)
Thanks Viral. To be clear, I’m a python user who’s cheering for Julia, because I live the problems of python and do see the potential of Julia as a better path. But unfortunately I’m not prepared to be the early adopter (at least in my day job), and will wait until other, braver users have sanded off the rough edges. God speed and good luck.
Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by ViralBShah on Sunday October 11, 2020 @09:25PM (#24750623)
That's a completely reasonable viewpoint. Many users of Julia and contributors start out experimenting with it and then end up bringing it into their work when they feel comfortable with it. I hope you will have the same experience one day.
Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by dmw_ng on Sunday October 11, 2020 @03:39PM (#24748433)
Regarding 2), code like "for row in pandas.DataFrame(...).iterrows():" where the DataFrame was populated by some array-based reader is creating an indirection. Most good pandas code of course doesn't look like this, but it's regularly unavoidable, hence "There are use cases where either representation is preferred". Without specifying our use case, it is meaningless to talk about "faster" or "slower".

For 3) there inherently is no optimal solution to "a problem with large performance-correctness tradeoffs", additionally users do not care only about speed, for a huge number of applications, absolute reproduction of precision may be the difference between a good simulation and data science quackery. We saw elsewhere in the thread that Julia's float parsing code at least presently handles certain syntaxes incorrectly. Ignoring performance, this is criteria for deciding whether a solution is fit for purpose at all.

The overall point otherwise makes sense: most DS folk don't and maybe shouldn't care about this stuff, however this is HN, and elsewhere in the comments there are plenty of examples of people who do.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by StefanKarpinski on Sunday October 11, 2020 @07:49PM (#24750124)
> there inherently is no optimal solution to "a problem with large performance-correctness tradeoffs"

You seem to be under the misapprehension that mainstream CSV libraries parse float values with reduced precision in order to go faster. They do not. A decimal floating-point string represents a precise mathematical value and the only acceptable value for a CSV parser to produce is that value correctly rounded to a Float64 (or some other type if requested). Any CSV parser that does anything else is simply incorrect.

> We saw elsewhere in the thread that Julia's float parsing code at least presently handles certain syntaxes incorrectly.

You may be referring to a bug mentioned elsewhere that fields like `-123.` with a leading minus sign and a trailing decimal point are misinterpreted as strings. That is a bug, plain and simple. It has nothing to do with float parsing speed/accuracy tradeoffs.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by mlthoughts2018 on Sunday October 11, 2020 @03:30PM (#24748360)
A typical user will rarely ever use the built in CSV library in Python, and would choose among the many third party options for much greater performance, ease of use, parity with rectangular data structure tools like pandas, and so forth.

Comparing anything against the built-in CSV reader in Python is pretty much an exercise in nothing.

In 20 years of programming Python professionally, I have used the built in CSV parser about 5 total times, and all were use cases where 10-20x improvement of CSV parser performance did not matter whatsoever to the application.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by StefanKarpinski on Sunday October 11, 2020 @03:33PM (#24748395)
The fact that the standard CSV reader is not good enough to actually use except in toy applications is itself an issue, frankly.
Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by mlthoughts2018 on Sunday October 11, 2020 @03:45PM (#24748483)
I disagree completely. It’s perfectly good enough for non-specialized use cases, which is exactly right for a stdlib offering. For anything else, factor it out as separate third party options (even if maintained by PSF itself) so users only install what they need for their special application.

One person may install something that’s blazingly fast. Someone else may install something because it can convert the data to an in memory parquet format, someone else may use something that can virtualize SQL queries over top of disk-backed csvs.

They should all be different for the nuance of each application.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by StefanKarpinski on Sunday October 11, 2020 @03:59PM (#24748601)
Interestingly, CSV.jl can do all of those. This seems like a classic case of lack of composability in Python: you need a different CSV parser for each and every application even though the core logic of parsing the CSV format is the same. This is because anything fast has to be implemented in very concrete, specialized C code. In Julia, you can write something generic and let the compiler specialize it for you, so you get many different ways of applying the same thing for free.
Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by drej on Sunday October 11, 2020 @04:04PM (#24748636)
Lack of composability? What? Of course you can use one parser for everything, what’s stopping you from doing that. Separating IO from business logic and composing the two is a pretty standard practice. Not sure I follow the argument here.
Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by coliveira on Sunday October 11, 2020 @05:16PM (#24749179)
The argument is simple: Python is by design made so that if you want things to go fast then you need to implement it in C. This creates a constant need to use specialized libraries (such as pandas), where in other languages they can simply do a better job in optimizing the standard library.
Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by mlthoughts2018 on Sunday October 11, 2020 @07:53PM (#24750149)
This is untrue, you can compartmentalize your C implementations using tools like Cython.

The fact that you write these as isolated special implementations is a good thing and not a deficiency of generics.

This way it can be gradual. You only target certain functions or modules for optimized C implementation, you don’t waste static typing overhead or compliance to a generic interface on the 99% of the code that will have no material gain from any optimization.

It’s similar with gradual typing in Python as well. Annotate what you need, omit annotations for what you don’t. Implement an extension module or multiple dispatch for what you need, use plain Python for everything else.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by mlthoughts2018 on Sunday October 11, 2020 @07:01PM (#24749857)
> “ In Julia, you can write something generic and let the compiler specialize it for you, so you get many different ways of applying the same thing for free.”

Python also lets you easily achieve this in many ways - notably fused typing in Cython.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by dagw on Monday October 12, 2020 @02:37AM (#24751967)
Just adding types doesn't give you that much extra performance in cython (2-3x at most in most cases in my experience) if you want 10x+ speed up you generally have to rewrite your code in a more 'cythonic' way.
Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by mlthoughts2018 on Monday October 12, 2020 @06:18PM (#24760105)
I’ve not had the same experience. Simply adding types and omitting CPython types (which results in simpler “basic C” loops and so on) gets 100x speed ups in most situations, and Cython has an annotation mode that highlights CPython bottlenecks to make this very easy and interactive to spot.

With numba it can be even more dramatic. Zero code changes, solely type annotation in the decorator, and you can often get 1000x speedup over pure Python, because numba can optimize away many of the extra CPython data model features that tight loop code may occasionally not need to use.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by dagw on Tuesday October 13, 2020 @04:02AM (#24763328)
Do you have any code you can share showing this speed up? Because I have written a lot of Cython over past 5 years, and unless my python code is monumentally stupid (and in that case I can get an order of magnitude or two speedup by just writing sane python), I have never seen anything close to 100x speedup in real world code. Even getting a 5x speed up over a baseline python/numpy implementation requires a fair amount of refactoring to make the code more cython friendly.

Same with Numba, despite its promises, I've never seen anything close to 100x speedups in the real world, and I've even seen a fair few cases where numba resulted in slower code compared to 'pure' python/numpy (although admittedly that was 2-3 years ago)

Sure I could probably design some pathological code where you might see 100x speed up by just adding type annotations, but that would probably require starting with some really inefficient python code.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by mlthoughts2018 on Wednesday October 14, 2020 @10:09PM (#24784060)
I do have code I can show, but I do not want to reveal my GitHub username attached to my Hacker News account.

Thankfully you don’t have to rely on me - tons of name brand Python scientific tools use Cython for speedups.

Pandas, for example, uses Cython heavily. Here is an example tutorial that may help you,

https://pandas.pydata.org/pandas-docs/stable/user_guide/enha...

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by mlthoughts2018 on Sunday October 11, 2020 @04:10PM (#24748685)
> “ Interestingly, CSV.jl can do all of those.“

That sounds like a poorly designed library to me. Instead of doing one thing well, it forces users to consume something meant as a jack of all trades, which may not meet their use case.

I wish such a thing wasn’t forced in a standard package - rather split into different ones. Then I can easily compose them according to my needs, instead of having the stdlib force feed me some set of tradeoffs I might not want.

I’m sure these extra third party libraries exist or will exist in Julia just as they do in Python and users will have lots of good options - but what a shame for people to take a needlessly myopic view that core libraries need to be obsessed either with performance or with breadth of use case coverage coupled into one library, which seems to purely be for macho bragging rights or something?

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by StefanKarpinski on Sunday October 11, 2020 @07:36PM (#24750052)
That you believe this violates the principle of "do one thing and do it well" indicates a certain "abstraction blindness". Do you really believe that "parse CSV to a data frame" and "parse CSV to a parquet file" and "parse CSV and apply a query to it in-place" are completely separate, unrelated things? It seems clear to me in any case that with the right abstraction, those are the same thing composed with different choices of what to do with the parsed data.

At a higher level, this seems like a classic Julia versus Python dynamic. In the Python ecosystem there are a dozen different versions of each thing that make different trade-offs and specialize in different ways. When you're picking one, you have to spend a week evaluating all the possible CSV parsers (for example).

In the Julia ecosystem, the ideal it to have one really high-quality, fast, flexible implementation that everyone collaborates on to make it great for all kinds of use cases. And the language design and the compiler make this possible, since you can write pretty abstract code and compose it with various types and get a really fast implementation. The annoying and tricky logic of parsing the CSV format only needs to be done once, and reused for all different situations.

This isn't done for "macho bragging rights" but because it is a waste of time and effort to implement a dozen half-baked versions of the same thing. When there are a dozen separate implementations of something like this, they also end up disagreeing on their behavior, which causes no end of headaches.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by drej on Monday October 12, 2020 @04:14AM (#24752414)
> In the Python ecosystem there are a dozen different versions of each thing that make different trade-offs and specialize in different ways. When you're picking one, you have to spend a week evaluating all the possible CSV parsers (for example).

It saddens me to read this weird statement. It saddens me as I was a rather early adopter in Julia (v0.3.2, if I remember correctly) and really believed its mission. I don't quite understand why various ecosystems cannot peacefully coexist without these untrue and completely avoidable statements.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by mlthoughts2018 on Sunday October 11, 2020 @07:58PM (#24750172)
> “ Do you really believe that "parse CSV to a data frame" and "parse CSV to a parquet file" and "parse CSV and apply a query to it in-place" are completely separate, unrelated things?“

Yes, absolutely. Very high level design goals are completely different between those use cases and you would be forced to make mutually exclusive trade offs to solve any one of those problems - which will directly lead to concessions in terms of the other use cases. No one generic csv parser can be optimal to all three.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by StefanKarpinski on Sunday October 11, 2020 @08:22PM (#24750315)
CSV.jl seems to be proof that you're wrong about that. More concretely, the only difference between parsing to a data frame, parsing to a parquet file, and executing a query over data is a) where you put the data in memory and b) optionally calling some code to operate on the data as you go. It's hard to see how those applications require radically different designs.
Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by mlthoughts2018 on Monday October 12, 2020 @06:13PM (#24760050)
This is not accurate. CSV.jl optimizes for speed but does not optimize for data transfer to other systems like Spark (which, by necessity, causes worse performance in order to add features around type marshaling).

Design for general case speed is directly at odds with designing either for executing SQL over top of the file (in which case the trade offs are about indexing the data for record-wise or column-wise operations) or type marshaling for an extremely narrow use case like reading into Spark.

For example, parsing for speed vs parsing for Spark interop are very likely to handle datetime parsing or null parsing significantly differently.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by cbkeller on Sunday October 11, 2020 @04:26PM (#24748813)
Well, the promise of overhead-free multiple dispatch is that you don't have to choose between a general solution with poor performance and a specific solution with good performance. You can have all the specific solutions you need in one place and automatically dispatch to the right one without any extra effort.

I know it sounds too good to be true, but my limited experience so far is that it really is true, with surprisingly few pitfalls (mostly, you have to think about type instability, which will be new to most, but is really not that hard to avoid).

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by mlthoughts2018 on Sunday October 11, 2020 @06:58PM (#24749843)
Multiple dispatch based on static typing only solves a very narrow set of optimization problems - most complex trade offs that would lead to the need for eg multiple different third party csv readers are not addressable at all by multiple dispatch.

I’d also point out that with fused typing in Cython, it’s also trivially easy to get overhead-free multiple dispatch in Python too, and unlike Julia, this had the benefit that it can be a gradual trade off, where you only bother writing the Cython module with autogenerated multiple dispatch implementations based on different types for the ~1% of use cases where it has any impact on the application, and you get the benefit of super easy to develop, flexible Python for everything else, with none of the code liability that comes from describing multiple dispatch generics in the 99% of the code that does not benefit from it.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by dklend122 on Sunday October 11, 2020 @11:13PM (#24751089)
You are very misinformed here.

Julia doesn't have static typing and there are a very large set of problems that are trivially solved with it's type system.

See the tables.jl ecosystem for example

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by mlthoughts2018 on Monday October 12, 2020 @06:25PM (#24760173)
I think you are misinformed. Runtime dispatch on multiple argument types is still using static typing under the hood (Julia is using this, just as Cython is).

The fact that input types are dynamic and resolved at runtime (which works identically in both Julia and Python using a Cython extension module) does not mean the multiple dispatch “is dynamic” (it’s still based on a registry of types that determine which overloaded implementation to select).

The only trade-off is whether you want to be able to extend this registry of static types mapping to implementations on the fly (similar to type classes in Haskell) which Julia supports natively and Python supports via tools like numba, or you need to ahead-of-time compile it (Cython).

This is a trade-off though, between AOT resolver speed vs JIT flexibility. It’s not definitely better one way or the other, and Cython gives you a level of control over explicit language features to enable or disable (eg Exception disabling) that is much better for some use cases.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by dklend122 on Tuesday October 13, 2020 @06:03AM (#24763979)
No. You're confusing static dispatch with static typing.

Julia can do both static and dynamic dispatch. The latter works with function barriers works to maintain codebases that are impossible to achieve with just one or the other.

There's no resolving trade-off because when Julia knows types and call time (or a union of them ) it can inline function calls.

Anyway, neither numba nor cython has the combin of features that allows for one to define a fast custom abstract array and have another package seamlessly define a subtype that works fast and with other data structures, overloading only the necessary functions. Then a third package can come and build on top using traits from the first and some weird solver.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by mlthoughts2018 on Wednesday October 14, 2020 @10:42PM (#24784308)
No, you are still misunderstanding static type dispatch within a dynamic language. The registry of overloaded specializations works based on static type information. That is not a requirement to have statically typed values (neither in Python nor Julia) but it is still statically typed.
Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by tikej on Sunday October 11, 2020 @07:53PM (#24750146)
> Multiple dispatch based on static typing only solves a very narrow set of optimization problems - most complex trade offs that would lead to the need for eg multiple different third party csv readers are not addressable at all by multiple dispatch.

How about multiple dispatch with dynamic (runtime) typing?

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by imtringued on Sunday October 11, 2020 @06:32PM (#24749687)
I think parents' point is that a fast CSV parser can be written once and then used to implement many different features. Meanwhile in python every library has to reimplement its own CSV parser because switching from C to python and then back to C would ruin performance. To avoid this context switch the csv parser has to be written again and again.
Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by mlthoughts2018 on Sunday October 11, 2020 @07:09PM (#24749902)
This is not true at all. Most libraries do not reimplement csv parsing - I’m saying only a select few libraries do this because they have very different design goals. For example optimizing for maximum rows per second parsed is a totally different design goal from optimizing to read into Spark DataFrame types to connect to Spark. Prioritizing one of these might come at the cost of the other, which is totally fine and having more than one library to choose from is a good thing.

> “ switching from C to python and then back to C would ruin performance.”

This is explicitly wrong in regards to Python. Optimizing Python often involves writing an implementation directly in C (or better, Cython) and autogenerating bindings that marshal between CPython native C types and the types of your extension module. This is extremely fast - as fast as calling native C code, there is no performance penalty for this.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by drej on Sunday October 11, 2020 @04:01PM (#24748621)
Except that it can. I hardly ever use something other than stdlib’s csv. It’s a perfectly good csv parser for production use.
Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by cbkeller on Sunday October 11, 2020 @04:10PM (#24748682)
Doesn't that validate the applicability of the benchmark then? GP said:

> A typical user will rarely ever use the built in CSV library in Python

as a criticism of the benchmark, but if a typical user does use stdlib’s csv after all, then it seems like your disagreement is perhaps with GP and not with Stefan.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by giantrobot on Sunday October 11, 2020 @04:29PM (#24748842)
It does validate the benchmark but that doesn't make the benchmark particularly useful. In both Python and Julia if loading your data from CSV is a bottleneck you'll do something else. If it's not a bottleneck it doesn't matter.

If you've got a Python code base it would cost far more in terms of effort and dollars to convert it all to Julia than to just find a better way to load data. If you've got a green field project and CSV reading is a big portion of the task load then it makes sense to pick Julia I guess.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by mlthoughts2018 on Sunday October 11, 2020 @04:16PM (#24748749)
No you’re mixing up two things.

1. Python’s std csv parser is very fast & versatile, perfectly good for a range of use cases that don’t have unusual needs.

2. For any production use cases whose needs aren’t met by the std csv parser, nobody would use it and nobody has to - plenty of other options exist (rightfully) as separate packages that allow the user to choose a different point of trade-off properties if they don’t like the std module’s defaults.

Nothing says the std isn’t good enough for production - it is. Just most people will use something application-specific and they have tons of options.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by formerly_proven on Sunday October 11, 2020 @05:48PM (#24749387)
> If float parsing is slow, make it faster.

Use a binary data format or hexfloats instead. Decimal floats are a pain and especially pointless if they are being generated from and converted back to IEEE 754.

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by coldtea on Monday October 12, 2020 @02:34AM (#24751959)
>You may be missing the point of the comparison, which is this: to compare the performance of the de facto standard CSV parsers of each system when used the way that a typical user would use them, i.e. to parse a CSV file into a data frame.

Well, in Python typically one would use pandas "to parse a CSV file into a data frame", not the standard csv parser (which doesn't deal with data frames anyway), no?

Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by cbkeller on Monday October 12, 2020 @02:47AM (#24752020)
That’s why Pandas read_csv is what they benchmarked
Re:CSV Reader Benchmarks: Julia Reads CSVs 10-20x Faster tha... by coldtea on Monday October 12, 2020 @03:06AM (#24752111)
Ah, alrighty then.