Coder Social home page Coder Social logo

Streaming get / post about tantalum HOT 8 OPEN

vivainio avatar vivainio commented on August 17, 2024
Streaming get / post

from tantalum.

Comments (8)

paulirotta avatar paulirotta commented on August 17, 2024

It is a worthy expansion.

When we do that, the complexity to watch for obscure hang states and performance suck is between the Worker thread, the Worker queue, and the source of the stream. On some devices we only use 2 Worker threads so locking a Worker for an indeterminate amount of time might be expensive.

Several approaches come to mind:

  1. reverse logic a bit and the stream source drives the process. Some more thought needed here
  2. create a dedicated thread for the duration of the streaming operation
  3. instead of stream, break the stream of data into a series of fixed-size byte[] buffer chunks, similar to iphone media framework and others. Here the risk is heap memory growth from queing, but proper dance between threads can keep that down.

from tantalum.

vivainio avatar vivainio commented on August 17, 2024

We should specify "writeReady" so that it should not block beyond what it takes to write to the OutputStream (i.e. to the http connection). That way, there is no more blocking than there is with the variant that takes byte[].

from tantalum.

vivainio avatar vivainio commented on August 17, 2024

Assigning to @jnynas as he has a working implementation is his own app already

from tantalum.

paulirotta avatar paulirotta commented on August 17, 2024

I've shifted the default number of worker threads from 4 to 2 in large part because flash writes seem to suck CPU cycles on some phones. For algorithm reasons we can't really run with less that 2 workers. A nice implementation thus might need to add a Thread per stream and Task.fork(Task.SERIAL_PRIORITY) to drop ready chunks of data into flash memory.

from tantalum.

vivainio avatar vivainio commented on August 17, 2024

On not blocking when reading; yeah, correct user code will have to read all of the stream and enqueue the data for background writing. The advantage of stream would mainly be to only store the data that needs to be stored; e.g. in case of base64 encoded content, we would stream in the data as one decoded memory block that then gets queued for writing

... or indeed manually fork a new Task to handle that stream, for each request

from tantalum.

paulirotta avatar paulirotta commented on August 17, 2024

Streaming large objects to flash memory file system could be quite useful, for example storing songs and videos on the memory card.

Let's keep this in the backlog

from tantalum.

vivainio avatar vivainio commented on August 17, 2024

Reopened, javadocs need to be added before closing the issue.

from tantalum.

paulirotta avatar paulirotta commented on August 17, 2024

Did some JavaDoc and minor thread hardening.

A unit test or example to validate is still needed

from tantalum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.