Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate workers for parsing and database insertions #137

Open
j-rausch opened this issue Sep 5, 2018 · 5 comments
Open

Separate workers for parsing and database insertions #137

j-rausch opened this issue Sep 5, 2018 · 5 comments
Labels
enhancement New feature or request help wanted Extra attention is required

Comments

@j-rausch
Copy link
Contributor

j-rausch commented Sep 5, 2018

Is your feature request related to a problem? Please describe.
Decouple UDF processes from the backend/database session.
Right now, when we run UDFRunner.apply_mt(), we create a number of UDF worker processes. These processes all own an sqlalchemy Session object and add/commit to the database at the end of their respective parsing loop.

Describe the solution you'd like
Make the UDF processes backend-agnostic, e.g. by having a set of separate BackendWorker processes handle the insertion of sentences. One possible way: Connect the output_queue of UDF to the input of BackendWorker, which receive Sentence lists and handle the sqlalchemy commits.

This will not fully decouple UDF from the backend, because the parser returns sqlalchemy-specific Sentence objects, but it could be one step towards that goal.

Additional context
This feature request refers to decoupling of parsing and backend.
There's likely more coupling with the backend later in the processing pipeline.

@lukehsiao lukehsiao added enhancement New feature or request help wanted Extra attention is required labels Sep 21, 2018
@HiromuHota
Copy link
Contributor

The apply/reducer architecture, which has been used by the snorkel-extraction project, may be used here too.

@HiromuHota
Copy link
Contributor

The Snorkel team has discussed multithreaded reduce at snorkel-team/snorkel#562.

@senwu
Copy link
Collaborator

senwu commented Nov 9, 2019

This is a great question! Is there a way to use the other package to do this instead of building our own code?

@HiromuHota
Copy link
Contributor

We could use (Py)Spark, Dask, etc. for distributed computing but the bottleneck would be the data persistence layer, i.e., PostgreSQL.
In other words, as long as we use PostgreSQL, it'll be the bottleneck and we end up doing ad-hoc performance optimizations here and there.

One idea is to use different appliers for different storage backends: one for in-memory, another for PostgreSQL, one another for Hive, etc.
The snorkel project (not snorkel-extraction) takes this approach for different computing frameworks (LFApplier, DaskLFApplier, SparkLFApplier), but Fonduer has more appliers to take care of, i.e., parser, mention_extractor, candidate_extractor, labeler, featurizer; and Fonduer has to worry about the data persistence layer too.

@senwu
Copy link
Collaborator

senwu commented Nov 9, 2019

That's one idea! I think it would be better to modularize so we can 1) have better support for distributed computing from other parties (e.g., PySpark, Dask ); 2) easy to extend to other data layers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is required
Projects
None yet
Development

No branches or pull requests

4 participants